package com.gopay.bis.dao.bankorder.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Service;

import com.gopay.bis.dao.bankorder.BcdlQueryBalanceDAO;
import com.gopay.common.base.dao.impl.BaseDAOImpl;
import com.gopay.common.domain.bank.BcdlQueryBalance;

/**
 * 自动结算查询余额DAOImpl
 * 
 * @BcdlQueryBalanceDAOImpl.java
 * @author zhengxue
 * @2016-2-17 下午6:04:23 www.gopay.com.cn Inc.All rights reserved.
 */
@Service("bcdlQueryBalanceDAO")
public class BcdlQueryBalanceDAOImpl extends BaseDAOImpl<BcdlQueryBalance, String> implements BcdlQueryBalanceDAO {

    @Override
    public List<BcdlQueryBalance> getBcdlQueryByBankCodeAndOrderStatus(String bankCode, String queryOrderStatus) {
        String hql = "from BcdlQueryBalance where queryBankCode=:queryBankCode and queryOrderStatus=:queryOrderStatus";
        Map<String, Object> param = new HashMap<String, Object>();
        param.put("queryBankCode", bankCode);
        param.put("queryOrderStatus", queryOrderStatus);
        List<BcdlQueryBalance> bcdlQuery = this.findByHql(hql, param);
        return bcdlQuery;
    }

    @Override
    public BcdlQueryBalance findBcdlQueryById(String orderId) {
        String hql = "from BcdlQueryBalance where queryOrderId=:queryOrderId";
        Map<String, Object> param = new HashMap<String, Object>();
        param.put("queryOrderId", orderId);
        List<BcdlQueryBalance> bcdlQuerys = this.findByHql(hql, param);
        if (bcdlQuerys != null && bcdlQuerys.size() != 0) {
            return bcdlQuerys.get(0);
        } else {
            return null;
        }
    }
}
